//
//  WOTimeIntervalsSection.m
//  WOPrototype
//
//  Created by Olof Millberg on 2010-04-28.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "WOTimeIntervalsSection.h"


@implementation WOTimeIntervalsSection
@synthesize timeIntervals, editable;

+ (id) timeIntervalsSectionWithTitle:(NSString *) aTitle list:(NSMutableArray *)list editable:(BOOL)isEditable
{
	WOTimeIntervalsSection *section = [[[WOTimeIntervalsSection alloc] initWithTitle:aTitle 
																				list:list
																			editable:isEditable] autorelease];
	return section;
}

- (id) initWithTitle:(NSString *)aTitle list:(NSMutableArray *)list editable:(BOOL)isEditable
{
	if (self = [super init])
	{
		self.title = aTitle;
		self.timeIntervals = list;
		self.editable = isEditable;
	}
	return self;
}

- (NSInteger) numberOfRows
{
	if (editable)
		return [timeIntervals count] + 1;
	else
		return [timeIntervals count];
}

- (NSString *) identifierAtRow:(NSInteger)row
{
	if (row < [timeIntervals count])
		return @"TimePickerCell";
	else
		return @"AddTimeCell";
}

- (CGFloat) heightForRow:(NSInteger)row
{
	return 44;
}

- (void) dealloc
{
	[timeIntervals release];
	[super dealloc];
}

@end
